import os
from configparser import ConfigParser
from common.handlepath import CONFDIR


class HandleConfig(ConfigParser):
    def __init__(self, config_file):
        self.config_file = config_file
        # 继承父类init方法
        super().__init__()
        self.read(self.config_file, encoding="utf-8")

    def writeData(self, section, option, value):
        # 写入数据
        self.set(section=section, option=option, value=value)
        # 写入到文件
        self.write(fp=open(self.config_file, "w"))


conf = HandleConfig(os.path.join(CONFDIR, "config.ini"))
